//
//  NSAttributedString+Extension.swift
//  JPWeibo
//
//  Created by 哇咔咔 on 2016/10/8.
//  Copyright © 2016年 jp. All rights reserved.
//

import UIKit

extension NSAttributedString {

    static func attributedStringWithFont(font: UIFont, emotion: JPEmotion) -> NSAttributedString {
        
        let image = UIImage(named: emotion.path!)
        let lineHeight = font.lineHeight
        
        //  创建文本附件,设置文本附件属性
        let attachment = JPTextAttachment()
        attachment.emotion = emotion
        attachment.image = image
        attachment.bounds = CGRect(x: 0, y: -4, width: lineHeight, height: lineHeight)
        
        let attributedStr = NSAttributedString(attachment: attachment)
        return attributedStr
    }
    
}
